package com.kfm.pm;

public class Dog {

    // 品种
    String breed;
    int age;
    String color;

    public Dog() {

    }

    public Dog(String breed) {
        this.breed = breed;
    }

    public Dog(String breed, int age) {
        // this(实参列表) --> 调用对应的重载的构造方法 并且必须写在构造方法的第一句
        this(breed);
        this.age = age;
    }

    public Dog(String breed, int age, String color) {
        this(breed, age);
//        this.breed = breed;
//        this.age = age;
        this.color = color;
    }

    public void bark() {
        System.out.println(breed + "狗叫！");
    }

    public void info() {
        System.out.println(breed + "颜色是" + color);
    }

    public void sayHello() {
        // 谁调用的sayHello方法，this就是谁
        this.info();
        System.out.println("你好");
    }

    public static void main(String[] args) {
        // 构建对象
        Dog jm = new Dog("金毛", 3, "金黄色");
//        jm.info();
        jm.sayHello();

        Dog kj = new Dog("柯基", 3, "棕色");
//        jm.info();
        kj.sayHello();
    }


}
